package com.pzr.demo.web.controller.test;

import org.activiti.engine.HistoryService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;

import com.google.gson.Gson;
import com.hgx.entity.AjaxResult;

/**
 * 
 * 流程测试
 * 
 * @time 2016-12-30
 * 
 * @author Administrator
 * 
 */
public class BaseController {

	public enum Status {
		ERROR, SUCCESS, WARN
	};

	private ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();//

	private Gson gson = new Gson();

	public String getJsonStr(AjaxResult rusultObj) {
		return gson.toJson(rusultObj);
	}

	/**
	 * 返回异常的
	 * 
	 * @return
	 */
	public String getErrorJsonStr(String message) {
		AjaxResult rusultObj = new AjaxResult(Status.ERROR.toString());
		rusultObj.setWarnMessage(message);
		return gson.toJson(rusultObj);
	}

	/**
	 * 返回成功的
	 * 
	 * @return
	 */
	public String getSuccessJsonStr(String message) {
		AjaxResult rusultObj = new AjaxResult(Status.SUCCESS.toString());
		rusultObj.setWarnMessage(message);
		return gson.toJson(rusultObj);
	}

	public RepositoryService getRepositoryService() {
		return engine.getRepositoryService();
	}

	public RuntimeService getRuntimeService() {
		return engine.getRuntimeService();
	}

	public HistoryService getHistoryService() {
		return engine.getHistoryService();
	}

}
